/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mdp.lab;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
 *
 * @author Oleg
 */
public class Index {
//    private ConcurrentHashMap<String,Set<String>> keyToFieldsMap = 
//            new ConcurrentHashMap<>();
    
    private ConcurrentHashMap<String, ConcurrentHashMap<String, String>> keyToFieldValuesMap = 
            new ConcurrentHashMap<>();
            
    public void putValue(String key, String field, String value) {
    }
    
    public Set<String> getFields(String key) {
        return null;
    }
    
    public String getValue(String key, String field) {
        return null;
    }
    
    public void putValues(String key, Map<String, String> values) {
        ConcurrentHashMap<String, String> storedValues = keyToFieldValuesMap.get(key);
        if( storedValues == null) {
            storedValues = keyToFieldValuesMap.putIfAbsent(
                    key, 
                    new ConcurrentHashMap<String, String>());
        }
        storedValues.putAll(values);
   }
    
    public Map<String, String> getValues(String key) {
        return Collections.unmodifiableMap(keyToFieldValuesMap.get(key));
    }
    
}
